package hyrpt

class PassRateController {
    def dynamicQueryService
    def passRate(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList=[]
        def passRate=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def passRateByStep=[]
        def passRateByPeople=[]
        def onceYieldByStep=[]
        def onceYieldByPeople=[]
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'passRate'
            passRate = dynamicQueryService.queryForList(params)
            if (passRate.size() > 0) {
                tableHeadList = passRate[0].keySet()
            }
            params.SYS_QUERY_NAME = 'passRateCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

            params.SYS_QUERY_NAME = 'passRateByStep'
            passRateByStep = dynamicQueryService.queryForList(params)

            params.SYS_QUERY_NAME = 'passRateByPeople'
            passRateByPeople = dynamicQueryService.queryForList(params)

            params.SYS_QUERY_NAME = 'onceYieldByStep'
            onceYieldByStep = dynamicQueryService.queryForList(params)

            params.SYS_QUERY_NAME = 'onceYieldByPeople'
            onceYieldByPeople = dynamicQueryService.queryForList(params)
        }
        print(params.docId)
        [startno:params.startno?:'',
         endno:params.endno?:'',
         pageSize:pageSize,
         totalCount: totalCount,
         pageSizeList: pageSizeList,
         tableHeadList:tableHeadList,
         passRate:passRate,
         passRateByStep:passRateByStep,
         passRateByPeople:passRateByPeople,
         onceYieldByStep:onceYieldByStep,
         onceYieldByPeople:onceYieldByPeople,
         startTime:params.startTime?:'',
         endTime:params.endTime?:'',
         stepDesc:params.stepDesc?:'',
         zerenren:params.zerenren?:'',
         czff:params.czff?:'',
         defectCode:params.defectCode?:'',
         state:params.state?:'',
         user:params.user?:'',
         eqp:params.eqp?:''
        ]
    }
}
